home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
001a
/
tlxutl10.zip
/
RANDPASS.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-01-25
|
3KB
|
123 lines
Program RandPass;
{ This is a Turbo Pascal 5.5 program designed to read a Telix 3.xx phone
directory file and create random passwords }
{$B-}
Type
Entries = Record
Name : Array [0..24] of Char;
Number : Array [0..16] of Char;
Baud, Parity, Data, Stop : Byte;
Script : Array [0..11] of Char;
Lastcall : Array [0..5] of Char;
TotCalls : Word;
Terminal : Byte;
Protocol : Char;
Toggles, fill1, fill2, DPrefNum : Byte;
Password : Array [0..13] of Char;
End;
Header = Record
Id : Longint;
ddf_vers, num_entries : Integer;
Pencrypted : Byte;
Spare : Array [0..54] of Byte;
End;
Var
PDir : File;
Report : Text;
Reporting : Boolean;
FName : String;
Choice : Char;
Entry : Entries;
head : Header;
Count : Byte;
EntryNo : Word;
Label
Over;
Function Padd (str : String; num : byte):String;
Var
Result : String;
Begin
FillChar (Result,num-ord(str[0])+1,' ');
Result[0] := Chr(num-ord(str[0]));
Result := Concat(str,result);
Padd := Result;
End;
Function CtoPas (Var str; size : byte):string;
Type
CString = Array [1..256] of Char;
Var
Count : Byte;
Result : String;
Begin
Count := 1;
While (CString(str)[Count] <> #0) and (Count < Size) Do
Begin
Result[Count] := CString(str)[Count];
Inc (Count);
End;
Result[0] := Chr(Count-1);
CtoPas := Result;
End;
Begin
Randomize;
Write ('Enter filename: ');
ReadLn (FName);
Assign (PDir,FName);
{$I-}
Reset (PDir,1);
{$I+}
Write ('Do you want reporting to None,Screen,Printer,File? (N/S/P/F) ');
ReadLn (Choice);
Reporting := True;
Case UpCase(Choice) Of
'S' : Assign (Report,'');
'P' : Assign (Report,'PRN');
'F' : Begin
Write ('Enter report file name: ');
ReadLn (FName);
Assign (Report,FName);
End;
Else
Reporting := False;
End;
If Reporting Then Rewrite (Report);
If IOResult <> 0 Then
Begin
WriteLn ('Error! File not found');
Goto over;
End;
Seek(PDir,0);
BlockRead (PDir,Head,SizeOf(Head));
For EntryNo := 0 To head.num_entries-1 Do
Begin
Seek(PDir,SizeOf(Head)+EntryNo*SizeOf(Entry));
BlockRead (PDir,Entry,SizeOf(Entry));
If Entry.Password[1] = #0 Then
For Count := 0 to 7 Do
Entry.Password[Count] := Chr(Random(26)+65);
Seek(PDir,SizeOf(Head)+EntryNo*SizeOf(Entry));
BlockWrite (PDir,Entry,SizeOf(Entry));
If Reporting Then
With Entry Do
WriteLn (Report,Padd(CtoPas(Name,SizeOf(Name)),SizeOf(Name)),
CToPas(Password,SizeOf(Password)));
End;
Close (PDir);
If Reporting Then Close (Report);
over:
End.